{
  "name": "Case 74 - Regional Bank VP Branch Performance Benchmarking",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -912,
        -208
      ],
      "id": "a80d763a-9bc5-44f1-91e8-ddb886a0d429",
      "name": "Monthly Schedule - 1st of Month"
    },
    {
      "parameters": {
        "actorId": {
          "__rl": true,
          "value": "Xb8osYTtOjlsgI6k9",
          "mode": "id",
          "cachedResultName": "Google Maps Scraper"
        },
        "customBody": "{\n  \"language\": \"en\",\n  \"maxReviews\": 100,\n  \"personalData\": true,\n  \"startUrls\": [\n    {\n      \"url\": \"https://www.google.com/maps/place/SBI+Branch+Dadar+West/@19.0159232,72.8348063,17z/data=!4m16!1m9!3m8!1s0x3be7cec4bfffffff:0x8b5f4a06c2b5db92!2sSBI+Branch+Dadar+West!8m2!3d19.0159181!4d72.8373812!9m1!1b1!16s%2Fg%2F1tkc0l4w!3m5!1s0x3be7cec4bfffffff:0x8b5f4a06c2b5db92!8m2!3d19.0159181!4d72.8373812!16s%2Fg%2F1tkc0l4w?entry=ttu&g_ep=EgoyMDI1MTIwOS4wIKXMDSoASAFQAw%3D%3D\"\n    }\n  ],\n  \"reviewsSort\": \"newest\",\n  \"reviewsOrigin\": \"all\"\n}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -720,
        -208
      ],
      "id": "e145c579-3fa7-481b-b1bd-be91064ac7ee",
      "name": "Scrape Branch Reviews",
      "credentials": {
        "apifyApi": {
          "id": "w5S6YBbbyUddEfQA",
          "name": "Apify account"
        }
      }
    },
    {
      "parameters": {
        "resource": "Datasets",
        "datasetId": "={{ $json.defaultDatasetId }}",
        "limit": 100
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -528,
        -208
      ],
      "id": "945e0e92-0c77-49ac-8e19-02d832edce0f",
      "name": "Get Dataset Items",
      "credentials": {
        "apifyApi": {
          "id": "w5S6YBbbyUddEfQA",
          "name": "Apify account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Filter out reviews without meaningful text\nconst items = $input.all();\nconst validItems = [];\n\nitems.forEach((item, index) => {\n  const text = item.json.text || item.json.textTranslated || '';\n  \n  // Skip if text is empty or too short\n  if (text.trim().length < 10) {\n    console.log(`Skipping item ${index}: Empty or too short review text`);\n    return;\n  }\n  \n  validItems.push(item);\n});\n\nconsole.log(`Filtered: ${items.length} total → ${validItems.length} valid reviews with text`);\n\nreturn validItems;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -336,
        -208
      ],
      "id": "e985697e-32bf-4f11-9702-261996bacc84",
      "name": "Validate Review Text"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4o"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "You are a Banking Operations Analyst. Analyze customer reviews about bank branch experience. Identify both positive aspects and areas for improvement.\n\nReturn ONLY this exact JSON format with NO other text:\n\n{\n  \"feedback_category\": \"Teller Service Quality|Wait Time Experience|Product Knowledge|Problem Resolution|Facility Condition|Digital Banking Support|Other\",\n  \"sentiment\": \"positive|negative|neutral|mixed\",\n  \"actionability\": \"Staff Recognition|Training Need|Staffing Adjustment|Facility Maintenance|Process Improvement|Technology Upgrade|Competitive Intelligence|No Action Needed\",\n  \"employee_mention\": \"employee name if mentioned, or empty string\",\n  \"key_feedback\": \"specific observation from review\",\n  \"key_quote\": \"most important sentence from review\"\n}\n\nCATEGORIES:\n\nTeller Service Quality = Teller friendliness, efficiency, professionalism\nKeywords: teller, banker, staff helpful, excellent service, rude, slow\nExample: \"Teller Maria was so helpful with my deposit\" → Teller Service Quality\n\nWait Time Experience = Queue times, appointment scheduling, speed\nKeywords: wait, line, queue, fast service, took forever, no wait\nExample: \"Waited 45 minutes just to cash a check\" → Wait Time Experience\n\nProduct Knowledge = Staff expertise on products, accurate information\nKeywords: explained well, didn't know, knowledgeable, confused, expert advice\nExample: \"Banker didn't understand mortgage options\" → Product Knowledge\n\nProblem Resolution = How issues are handled, complaint resolution\nKeywords: resolved issue, fixed problem, couldn't help, escalated, manager helped\nExample: \"Manager Sarah resolved my overdraft issue immediately\" → Problem Resolution\n\nFacility Condition = Cleanliness, ATM functionality, parking, accessibility\nKeywords: clean, dirty, ATM broken, parking, accessible, modern facility\nExample: \"ATM always out of service\" → Facility Condition\n\nDigital Banking Support = Mobile app help, online banking assistance\nKeywords: app, online banking, digital, mobile deposit, website\nExample: \"Staff helped me set up mobile banking\" → Digital Banking Support\n\nOther = Everything else\n\nSENTIMENT:\n- positive: Praise, satisfaction, appreciation\n- negative: Complaints, dissatisfaction, problems\n- neutral: Factual observations, no strong opinion\n- mixed: Both positive and negative elements\n\nACTIONABILITY:\n- Staff Recognition: Positive employee mentions for awards/bonuses\n- Training Need: Knowledge gaps, service quality issues\n- Staffing Adjustment: Wait time issues, understaffing\n- Facility Maintenance: Building/equipment repairs needed\n- Process Improvement: Workflow inefficiencies identified\n- Technology Upgrade: Digital banking issues\n- Competitive Intelligence: Customer switching banks, rate comparisons\n- No Action Needed: General observation\n\nEMPLOYEE_MENTION:\n- Extract employee names if mentioned (Maria, John, Sarah, etc.)\n- Leave empty if no employee named\n- Extract first name only\n\nReturn ONLY the JSON. No explanation. Start with { and end with }"
            },
            {
              "content": "=Analyze this bank branch review:\n\nBranch: {{ $json.title }}\nCustomer: {{ $json.name }}\nRating: {{ $json.stars }} stars\nDate: {{ $json.publishedAtDate }}\nReview: {{ $json.text }}\n\nReturn only JSON."
            }
          ]
        },
        "builtInTools": {},
        "options": {
          "maxTokens": 500,
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        -144,
        -208
      ],
      "id": "4da74162-473e-4265-8613-f6d5916071cd",
      "name": "AI: Analyze Branch Feedback",
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// ENHANCED PARSER WITH VALIDATION\nconst items = [];\nconst input = $input.all();\n\nfunction extractJSON(text) {\n  const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n  if (!jsonMatch) return null;\n  return jsonMatch[0];\n}\n\ninput.forEach((item, index) => {\n  try {\n    let aiText = item.json.output[0].content[0].text || '';\n    \n    // Clean markdown and extra text\n    aiText = aiText\n      .replace(/```json/gi, '')\n      .replace(/```/g, '')\n      .trim();\n    \n    // Extract JSON\n    const jsonStr = extractJSON(aiText);\n    \n    if (!jsonStr) {\n      throw new Error('No JSON found in response');\n    }\n    \n    // Parse\n    const parsed = JSON.parse(jsonStr);\n    \n    // Validate required fields\n    if (!parsed.feedback_category || !parsed.sentiment || !parsed.actionability) {\n      throw new Error('Missing required fields');\n    }\n    \n    items.push({ json: parsed });\n    \n  } catch (error) {\n    console.error(`Parse error for item ${index}:`, error.message);\n    \n    items.push({\n      json: {\n        feedback_category: 'Other',\n        sentiment: 'neutral',\n        actionability: 'No Action Needed',\n        employee_mention: '',\n        key_feedback: 'Parse error',\n        key_quote: ''\n      }\n    });\n  }\n});\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        176,
        -208
      ],
      "id": "fcde0d20-e93d-40fb-9408-1607531bf07b",
      "name": "Parse AI Response"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cat",
              "name": "feedback_category",
              "value": "={{ $json.feedback_category }}",
              "type": "string"
            },
            {
              "id": "sent",
              "name": "sentiment",
              "value": "={{ $json.sentiment }}",
              "type": "string"
            },
            {
              "id": "action",
              "name": "actionability",
              "value": "={{ $json.actionability }}",
              "type": "string"
            },
            {
              "id": "employee",
              "name": "employee_mention",
              "value": "={{ $json.employee_mention }}",
              "type": "string"
            },
            {
              "id": "feedback",
              "name": "key_feedback",
              "value": "={{ $json.key_feedback && $json.key_feedback.includes('Parse error') ? 'Not sufficient data available' : $json.key_feedback }}",
              "type": "string"
            },
            {
              "id": "quote",
              "name": "key_quote",
              "value": "={{ $json.key_quote && $json.key_quote !== '' ? $json.key_quote : 'No quote available' }}",
              "type": "string"
            },
            {
              "id": "date",
              "name": "review_date",
              "value": "={{ $('Validate Review Text').item.json.publishedAtDate }}",
              "type": "string"
            },
            {
              "id": "customer",
              "name": "customer_name",
              "value": "={{ $('Validate Review Text').item.json.name }}",
              "type": "string"
            },
            {
              "id": "rating",
              "name": "star_rating",
              "value": "={{ $('Validate Review Text').item.json.stars }}",
              "type": "number"
            },
            {
              "id": "text",
              "name": "review_text",
              "value": "={{ $('Validate Review Text').item.json.textTranslated || $('Validate Review Text').item.json.text }}",
              "type": "string"
            },
            {
              "id": "url",
              "name": "review_url",
              "value": "={{ $('Validate Review Text').item.json.reviewUrl }}",
              "type": "string"
            },
            {
              "id": "branch",
              "name": "branch_location",
              "value": "={{ $('Validate Review Text').item.json.address }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        400,
        -208
      ],
      "id": "feb321a1-0368-4b93-8d05-d14850683f8d",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1tL3B6ojVZ2IxyIrHUqKnn-HFJZs3BjUzN6W7bcNd594",
          "mode": "list",
          "cachedResultName": "Case 74 - Bank sheet headers",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tL3B6ojVZ2IxyIrHUqKnn-HFJZs3BjUzN6W7bcNd594/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tL3B6ojVZ2IxyIrHUqKnn-HFJZs3BjUzN6W7bcNd594/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Review_Date": "={{ $json.review_date }}",
            "Customer_Name": "={{ $json.customer_name }}",
            "Star_Rating": "={{ $json.star_rating }}",
            "Review_Text": "={{ $json.review_text }}",
            "Feedback_Category": "={{ $json.feedback_category }}",
            "Sentiment": "={{ $json.sentiment }}",
            "Actionability": "={{ $json.actionability }}",
            "Employee_Mention": "={{ $json.employee_mention }}",
            "Key_Feedback": "={{ $json.key_feedback }}",
            "Key_Quote": "={{ $json.key_quote }}",
            "Review_URL": "={{ $json.review_url }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Review_Date",
              "displayName": "Review_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer_Name",
              "displayName": "Customer_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Star_Rating",
              "displayName": "Star_Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Review_Text",
              "displayName": "Review_Text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Feedback_Category",
              "displayName": "Feedback_Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sentiment",
              "displayName": "Sentiment",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Actionability",
              "displayName": "Actionability",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Employee_Mention",
              "displayName": "Employee_Mention",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Key_Feedback",
              "displayName": "Key_Feedback",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Key_Quote",
              "displayName": "Key_Quote",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Review_URL",
              "displayName": "Review_URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        592,
        -208
      ],
      "id": "aca64bf7-48e9-4c52-87da-96fbc3cd98d1",
      "name": "Log to Google Sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "LOs2dbk9lby0NfDM",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const items = $('Edit Fields').all();\n\nif (items.length === 0) {\n  return [{ json: { total_reviews: 0, avg_rating: 0, category_breakdown: {}, sentiment_breakdown: {}, actionability_breakdown: {}, employee_recognition: {}, competitive_mentions: 0, top_positive: [], top_negative: [], branch_location: 'Unknown' } }];\n}\n\nconst categoryCount = {};\nconst sentimentCount = {};\nconst actionabilityCount = {};\nconst employeeCount = {};\nconst positiveItems = [];\nconst negativeItems = [];\nlet totalRating = 0;\nlet competitiveMentions = 0;\nconst branch_location = items[0].json.branch_location || 'Unknown';\n\nitems.forEach(item => {\n  const data = item.json;\n  const category = data.feedback_category || 'Other';\n  categoryCount[category] = (categoryCount[category] || 0) + 1;\n  const sentiment = data.sentiment || 'neutral';\n  sentimentCount[sentiment] = (sentimentCount[sentiment] || 0) + 1;\n  const action = data.actionability || 'No Action Needed';\n  actionabilityCount[action] = (actionabilityCount[action] || 0) + 1;\n  \n  // Track employee mentions\n  if (data.employee_mention && data.employee_mention.trim() !== '') {\n    const empName = data.employee_mention.trim();\n    if (!employeeCount[empName]) {\n      employeeCount[empName] = { positive: 0, negative: 0, total: 0 };\n    }\n    employeeCount[empName].total += 1;\n    if (sentiment === 'positive') {\n      employeeCount[empName].positive += 1;\n    } else if (sentiment === 'negative') {\n      employeeCount[empName].negative += 1;\n    }\n  }\n  \n  // Track competitive intelligence\n  if (action === 'Competitive Intelligence') {\n    competitiveMentions += 1;\n  }\n  \n  totalRating += data.star_rating || 0;\n  \n  const feedbackItem = {\n    feedback: data.key_feedback || '',\n    quote: data.key_quote || '',\n    customer: data.customer_name || 'Anonymous',\n    date: data.review_date || '',\n    rating: data.star_rating || 0,\n    url: data.review_url || '',\n    category: category,\n    actionability: action,\n    employee: data.employee_mention || ''\n  };\n  \n  if (sentiment === 'positive') {\n    positiveItems.push(feedbackItem);\n  } else if (sentiment === 'negative') {\n    negativeItems.push(feedbackItem);\n  }\n});\n\n// Sort by rating\npositiveItems.sort((a, b) => b.rating - a.rating);\nnegativeItems.sort((a, b) => a.rating - b.rating);\n\nconst topPositive = positiveItems.slice(0, 5);\nconst topNegative = negativeItems.slice(0, 5);\nconst avgRating = items.length > 0 ? (totalRating / items.length).toFixed(2) : 0;\n\n// Convert employee object to sorted array\nconst employeeArray = Object.keys(employeeCount).map(name => ({\n  name: name,\n  positive: employeeCount[name].positive,\n  negative: employeeCount[name].negative,\n  total: employeeCount[name].total,\n  net_score: employeeCount[name].positive - employeeCount[name].negative\n})).sort((a, b) => b.net_score - a.net_score);\n\nreturn [{ json: { total_reviews: items.length, avg_rating: avgRating, category_breakdown: categoryCount, sentiment_breakdown: sentimentCount, actionability_breakdown: actionabilityCount, employee_recognition: employeeArray, competitive_mentions: competitiveMentions, top_positive: topPositive, top_negative: topNegative, branch_location: branch_location } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        784,
        -208
      ],
      "id": "76354369-3679-41f9-ab42-a5bb4c2a7234",
      "name": "Aggregate Branch Performance"
    },
    {
      "parameters": {
        "sendTo": "regionalvp@bank.com",
        "subject": "=Monthly Branch Performance Report - {{ $json.branch_location }}",
        "emailType": "text",
        "message": "=MONTHLY BRANCH PERFORMANCE REPORT\n=====================================\nBranch: {{ $json.branch_location }}\nReport Period: {{ new Date().toLocaleDateString() }}\n\n📊 PERFORMANCE OVERVIEW:\nTotal Reviews Analyzed: {{ $json.total_reviews }}\nAverage Rating: {{ $json.avg_rating }} / 5.0 stars\n{{ parseFloat($json.avg_rating) >= 4.5 ? '🏆 EXCELLENT PERFORMANCE' : parseFloat($json.avg_rating) >= 4.0 ? '✅ GOOD PERFORMANCE' : parseFloat($json.avg_rating) >= 3.5 ? '⚠️ NEEDS IMPROVEMENT' : '🚨 URGENT ATTENTION REQUIRED' }}\n\nFEEDBACK CATEGORIES:\n{{ Object.keys($json.category_breakdown).map(cat => cat + ': ' + $json.category_breakdown[cat] + ' mentions').join('\\n') }}\n\nSENTIMENT BREAKDOWN:\n{{ Object.keys($json.sentiment_breakdown).map(sent => sent.toUpperCase() + ': ' + $json.sentiment_breakdown[sent] + ' (' + Math.round((parseFloat($json.sentiment_breakdown[sent]) / parseFloat($json.total_reviews)) * 100) + '%)').join('\\n') }}\n\nACTIONABLE ITEMS:\n{{ Object.keys($json.actionability_breakdown).map(action => action + ': ' + $json.actionability_breakdown[action]).join('\\n') }}\n\n⭐ EMPLOYEE RECOGNITION (Top Performers):\n{{ $json.employee_recognition.slice(0, 5).map((emp, i) => (i+1) + '. ' + emp.name + ' - ' + emp.total + ' mentions (' + emp.positive + ' positive, ' + emp.negative + ' negative) | Net Score: +' + emp.net_score).join('\\n') }}\n{{ $json.employee_recognition.length === 0 ? 'No employees mentioned by name this period' : '' }}\n\n✅ TOP 5 POSITIVE HIGHLIGHTS:\n{{ $json.top_positive.map((item, i) => (i+1) + '. [' + item.category + '] - ⭐' + item.rating + '/5' + (item.employee ? ' | Employee: ' + item.employee : '') + '\\n   Feedback: ' + item.feedback + '\\n   Quote: \"' + item.quote + '\"\\n   Customer: ' + item.customer + ' | ' + item.date).join('\\n\\n') }}\n{{ $json.top_positive.length === 0 ? 'No positive reviews this period' : '' }}\n\n❌ TOP 5 AREAS FOR IMPROVEMENT:\n{{ $json.top_negative.map((item, i) => (i+1) + '. [' + item.category + '] - ⭐' + item.rating + '/5' + (item.employee ? ' | Employee: ' + item.employee : '') + '\\n   Feedback: ' + item.feedback + '\\n   Quote: \"' + item.quote + '\"\\n   Customer: ' + item.customer + ' | ' + item.date).join('\\n\\n') }}\n{{ $json.top_negative.length === 0 ? 'No negative reviews this period' : '' }}\n\n🎯 RECOMMENDED ACTIONS:\n\n{{ $json.actionability_breakdown['Staff Recognition'] ? '1. EMPLOYEE AWARDS: ' + $json.actionability_breakdown['Staff Recognition'] + ' staff members deserve recognition\\n   → Forward employee recognition list to Branch Manager for monthly awards\\n   → Consider featuring top performers in regional newsletter\\n' : '' }}\n\n{{ $json.actionability_breakdown['Training Need'] ? '2. TRAINING PROGRAMS: ' + $json.actionability_breakdown['Training Need'] + ' reviews indicate knowledge gaps\\n   → Schedule product knowledge refresher for all staff\\n   → Review specific complaints for targeted training\\n' : '' }}\n\n{{ $json.actionability_breakdown['Staffing Adjustment'] ? '3. STAFFING LEVELS: ' + $json.actionability_breakdown['Staffing Adjustment'] + ' reviews mention wait times\\n   → Analyze peak hour traffic patterns\\n   → Consider additional teller during lunch rush (12-2 PM)\\n' : '' }}\n\n{{ $json.actionability_breakdown['Facility Maintenance'] ? '4. FACILITY ISSUES: ' + $json.actionability_breakdown['Facility Maintenance'] + ' maintenance items identified\\n   → Schedule immediate repairs (ATM, HVAC, etc.)\\n   → Review facility maintenance contract performance\\n' : '' }}\n\n{{ $json.actionability_breakdown['Process Improvement'] ? '5. PROCESS OPTIMIZATION: ' + $json.actionability_breakdown['Process Improvement'] + ' process inefficiencies noted\\n   → Review current workflows with branch manager\\n   → Benchmark against top-performing branches\\n' : '' }}\n\n{{ $json.actionability_breakdown['Technology Upgrade'] ? '6. DIGITAL BANKING: ' + $json.actionability_breakdown['Technology Upgrade'] + ' technology issues reported\\n   → Escalate to IT department\\n   → Provide additional staff training on mobile banking support\\n' : '' }}\n\n{{ $json.competitive_mentions > 0 ? '7. COMPETITIVE INTELLIGENCE: ' + $json.competitive_mentions + ' reviews mention competitor comparisons\\n   → Review pricing competitiveness\\n   → Analyze customer switching reasons\\n   → Develop retention strategies\\n' : '' }}\n\n📈 BENCHMARKING INSIGHTS:\n{{ parseFloat($json.avg_rating) >= 4.5 ? '🏆 This branch is a TOP PERFORMER - Use as training model for other branches' : '' }}\n{{ parseFloat($json.avg_rating) >= 4.0 && parseFloat($json.avg_rating) < 4.5 ? '✅ Above average performance - Share best practices regionally' : '' }}\n{{ parseFloat($json.avg_rating) >= 3.5 && parseFloat($json.avg_rating) < 4.0 ? '⚠️ Average performance - Implement improvement plan within 30 days' : '' }}\n{{ parseFloat($json.avg_rating) < 3.5 ? '🚨 Below expectations - Schedule immediate intervention meeting with Branch Manager' : '' }}\n\n💼 BOARD REPORTING METRICS:\n- Customer Satisfaction Score: {{ $json.avg_rating }}/5.0\n- Net Promoter Score Proxy: {{ Math.round(((parseFloat($json.sentiment_breakdown.positive || 0) - parseFloat($json.sentiment_breakdown.negative || 0)) / parseFloat($json.total_reviews)) * 100) }}%\n- Service Quality Index: {{ $json.category_breakdown['Teller Service Quality'] ? 'Mentioned in ' + $json.category_breakdown['Teller Service Quality'] + ' reviews' : 'Not frequently mentioned' }}\n- Digital Adoption Indicator: {{ $json.category_breakdown['Digital Banking Support'] ? $json.category_breakdown['Digital Banking Support'] + ' digital banking interactions' : 'Low digital engagement' }}\n\nNEXT STEPS:\n1. Branch Manager to address top 3 negative items within 7 days\n2. HR to process employee recognition awards\n3. Facilities to schedule any required maintenance\n4. Include performance data in next Regional Leadership Meeting\n5. {{ parseFloat($json.avg_rating) < 4.0 ? 'Schedule 1-on-1 coaching session with Branch Manager' : 'Continue monitoring performance trends' }}\n\nFull review details available in Google Sheets dashboard.\n\nGenerated: {{ new Date().toLocaleDateString() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        976,
        -208
      ],
      "id": "77a7bb9f-784b-4b06-943f-dac21f060049",
      "name": "Send Monthly Performance Report",
      "webhookId": "04da3cc2-d3bc-4111-a0a5-b8d9d80b5d97",
      "credentials": {
        "gmailOAuth2": {
          "id": "cyqCGWcggZNMcSOv",
          "name": "Gmail account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Monthly Schedule - 1st of Month": {
      "main": [
        [
          {
            "node": "Scrape Branch Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Branch Reviews": {
      "main": [
        [
          {
            "node": "Get Dataset Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Dataset Items": {
      "main": [
        [
          {
            "node": "Validate Review Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Review Text": {
      "main": [
        [
          {
            "node": "AI: Analyze Branch Feedback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI: Analyze Branch Feedback": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Log to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Google Sheet": {
      "main": [
        [
          {
            "node": "Aggregate Branch Performance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Branch Performance": {
      "main": [
        [
          {
            "node": "Send Monthly Performance Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d2311bd6-ae7c-4db6-b8c4-45d968607732",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "3a43da28588548e21903e71cf1dc3ddd65c24bf0c62e7e4b77542ffe87ad79c6"
  },
  "id": "XAwDQFThc4BobsxK",
  "tags": []
}